<?php

namespace app\controllers;

use Yii;
use app\tools\Re;
use app\models\Banner;

class BannerController extends BaseController {
  public function actionList(){
    $list = Banner::find()->where(['status' => 1])->orderBy('sort desc, created_at desc')->all();
    $data = [];
    if ($list) {
      foreach($list as $v) {
        $data[] = [
          'id' => $v->id,
          'title' => $v->title,
          'cover' => $v->cover,
          'good_id' => $v->good_id,
          'target_type' => $v->target_type
        ];
      }
    }
    return Re::data(['data' => $data]);
  }
}
